﻿#include "InstructionTurnTableCloseCircuit.h"

#include "ScriptRunner.h"
#include "TurnTableCodec.h"
#include "StateChecker.h"
#include "Device.h"

__SCRIPTINSTRUCTION_REGISTER(InstructionTurnTableCloseCircuit,ScriptInstruction::Instruction_TurnTable_CloseCircuit,&InstructionTurnTableCloseCircuit::fromByteArray1);

InstructionTurnTableCloseCircuit::InstructionTurnTableCloseCircuit()
{
  instructionFlag = Instruction_TurnTable_CloseCircuit;
}

InstructionTurnTableCloseCircuit::InstructionTurnTableCloseCircuit(InstructionTurnTableCloseCircuit const& instructionTurnTableCloseCircuit)
{
  *this=instructionTurnTableCloseCircuit;
}

InstructionTurnTableCloseCircuit& InstructionTurnTableCloseCircuit::operator=(InstructionTurnTableCloseCircuit const & instructionTurnTableCloseCircuit)
{
  *(ScriptInstruction*)this=instructionTurnTableCloseCircuit;
  return *this;
}

InstructionTurnTableCloseCircuit::~InstructionTurnTableCloseCircuit()
{}


void InstructionTurnTableCloseCircuit::run()
{
  scriptRunner->sendInstruction(deviceId,TurnTableCodec::TurnTable_CloseCircuit);
  StateChecker<bool>::next_ifConditionReached(&Device::getTurnTable_runningState_circuit,
                                              true,
                                              deviceId,
                                              scriptRunner);
}

QString InstructionTurnTableCloseCircuit::toString()
{
  return QStringLiteral("转台闭合");
}

QByteArray InstructionTurnTableCloseCircuit::toByteArray()
{
  return ScriptInstruction::toByteArray();
}

ScriptInstruction* InstructionTurnTableCloseCircuit::fromByteArray1(char * const src,int size,int * offset)
{
  (void)src;
  (void)size;
  (void)offset;
  return new InstructionTurnTableCloseCircuit();
}
